home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / host contacted / jikes.lha / jikes-1.11 / src / option.h < prev    next >
C/C++ Source or Header  |  2000-01-16  |  3KB  |  172 lines

  1. // $Id: option.h,v 1.18 2000/01/07 21:23:58 lord Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10.  
  11. #ifndef option_INCLUDED
  12. #define option_INCLUDED
  13.  
  14. #include "config.h"
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <ctype.h>
  18. #include "code.h"
  19. #include "tuple.h"
  20. #ifdef AMIGAOS_FILE_SYSTEM
  21. #include <unistd.h>
  22. #include <sys/param.h>
  23. #endif
  24.  
  25. #ifdef HAVE_LIB_ICU_UC
  26. # include <ucnv.h>
  27. #endif
  28.  
  29. class ArgumentExpander
  30. {
  31. public:
  32.  
  33.     int argc;
  34.     char **argv;
  35.  
  36.     ArgumentExpander(int, char **);
  37.  
  38.     ArgumentExpander(Tuple<char> &);
  39.  
  40.     ~ArgumentExpander()
  41.     {
  42.         for (int i = 0; i < argc; i++)
  43.             delete [] argv[i];
  44.         delete [] argv;
  45.     }
  46.  
  47.     bool ArgumentExpanded(Tuple<char *> &, char *);
  48. };
  49.  
  50.  
  51. class KeywordMap
  52. {
  53. public:
  54.     wchar_t *name;
  55.     int length,
  56.         key;
  57. };
  58.  
  59.  
  60. class OptionError
  61. {
  62. public:
  63.     int kind;
  64.     wchar_t *name;
  65.  
  66.     OptionError(int kind_, char *str) : kind(kind_)
  67.     {
  68.         int length = strlen(str);
  69.         name = new wchar_t[length + 1];
  70.         for (int i = 0; i < length; i++)
  71.             name[i] = str[i];
  72.         name[length] = U_NULL;
  73.  
  74.         return;
  75.     }
  76.  
  77.     ~OptionError() { delete [] name; }
  78. };
  79.  
  80.  
  81. class Ostream;
  82.  
  83. class Option
  84. {
  85. #ifdef WIN32_FILE_SYSTEM
  86.     char main_disk,
  87.          *current_directory[128];
  88.  
  89. public:
  90.     bool BadMainDisk() { return main_disk == 0; }
  91.  
  92.     bool IsMainDisk(char c) { return c != 0 && current_directory[c] == current_directory[main_disk]; }
  93.  
  94.     void SaveCurrentDirectoryOnDisk(char);
  95.  
  96.     void ResetCurrentDirectoryOnDisk(char d)
  97.     {
  98.         if (d != 0)
  99.         {
  100.             assert(current_directory[d]);
  101.  
  102.             SetCurrentDirectory(current_directory[d]);
  103.         }
  104.     }
  105.     void SetMainCurrentDirectory()
  106.     {
  107.         SetCurrentDirectory(current_directory[main_disk]);
  108.     }
  109.     char *GetMainCurrentDirectory()
  110.     {
  111.         return current_directory[main_disk];
  112.     }
  113. #elif defined(AMIGAOS_FILE_SYSTEM)
  114. public:
  115.     char *GetMainCurrentDirectory()
  116.     {
  117.     static char buf[MAXPATHLEN+1];
  118.     return getcwd(buf, sizeof(buf));
  119.     }
  120. #endif
  121.  
  122. public:
  123.     char *default_path,
  124.          *classpath,
  125.          *directory,
  126.          *dependence_report_name,
  127.          *encoding;
  128.  
  129. #ifdef HAVE_LIB_ICU_UC
  130.          UConverter *converter;
  131. #endif
  132.          
  133.     Tuple<KeywordMap> keyword_map;
  134.     Tuple<OptionError *> bad_options;
  135.  
  136.     bool nowrite,
  137.          deprecation,
  138.          O,
  139.          g,
  140.          verbose,
  141.          depend,
  142.          nowarn,
  143.          classpath_search_order,
  144.          zero_defect;
  145.     int first_file_index;
  146.  
  147.     int debug_trap_op;
  148.  
  149.     bool debug_dump_lex,
  150.          debug_dump_ast,
  151.          debug_unparse_ast,
  152.          debug_unparse_ast_debug,
  153.          debug_dump_class,
  154.          nocleanup,
  155.          incremental,
  156.          makefile,
  157.      dependence_report,
  158.          bytecode,
  159.          full_check,
  160.          unzip,
  161.          dump_errors,
  162.          errors,
  163.          comments,
  164.          pedantic;
  165.  
  166.     Option(ArgumentExpander &);
  167.  
  168.     ~Option();
  169. };
  170.  
  171. #endif /* option_INCLUDED */
  172.